#pragma once
namespace html { namespace dom
{
  using namespace std;

  struct node;
  
  /// @brief helper class, that provides access to the tag related 
  /// access methods for a linked nodes collection
  struct tag_accessor {

    /// @brief initialize accessor with a nodes collection
    tag_accessor(nodes& _nodes) : nodes_(_nodes) {}
    tag_accessor& operator=( symbol _tagnname ) { 
      // brief iterate all nodes
      for( nodes::iterator it=nodes_.begin(); it!=nodes_.end(); it++ )
        it->tag() = _tagnname;
    }
  private:
    /// @brief nodes that will be accessed
    nodes nodes_;
  };

  /// @brief helper class, that provides access to the id related 
  /// access methods for a linked nodes collection
  struct id_accessor {

    /// @brief initialize accessor with a nodes collection
    id_accessor(nodes& _nodes) : nodes_(_nodes) {}
    id_accessor& operator=( symbol _id ) { 
      // brief iterate all nodes
      for( nodes::iterator it=nodes_.begin(); it!=nodes_.end(); it++ )
        it->id() = _id;
    }
  private:
    /// @brief nodes that will be accessed
    nodes nodes_;
  };

  /// @brief helper class, that provides access to the class related access 
  /// methods for a linked nodes collection
  struct class_accessor {

    /// @brief initialize accessor with a nodes collection
    class_accessor(nodes& _nodes) : nodes_(_nodes) {}
    /// @brief add one symbol to the set of classes in all contained nodes.
    /// (same as classes::operator+=)
    class_accessor& operator+= (symbol _sym) {
      // brief iterate all nodes
      for( nodes::iterator it=nodes_.begin(); it!=nodes_.end(); it++ )
        // add class symbol to the current node's classes
        it->classes() += _sym;
      return *this;
    }
    /// @brief remove one symbol from the set of classes in all contained nodes.
    /// (same as classes::operator+=)
    class_accessor& operator-= (symbol _sym) {
      // brief iterate all nodes
      for( nodes::iterator it=nodes_.begin(); it!=nodes_.end(); it++ )
        // remove class symbol from the current node's classes
        it->classes() -= _sym;
      return *this;
    }
  private:
    /// @brief nodes that will be accessed
    nodes nodes_;
  };

  /// @brief helper class, that provides access to the text related access 
  /// methods for a linked nodes collection
  struct text_accessor {

    /// @brief initialize accessor with a nodes collection
    text_accessor(nodes& _nodes) : nodes_(_nodes) {}
    text_accessor& operator+=( const string& _text ) { 
      // brief iterate all nodes
      for( nodes::iterator it=nodes_.begin(); it!=nodes_.end(); it++ )
        (*it) += _text;
    }
  private:
    /// @brief nodes that will be accessed
    nodes nodes_;
  };

} }
